/*
 * error.c
 *
 *  Created on: Jun 1, 2014
 *      Author: Lhmily
 */
#include "../include/base.h"

char *program_name;
void error(int status, int err, char *fmt, ...) {
	va_list ap;

	va_start(ap, fmt);
	fprintf(stderr, "%s: ", program_name);
	vfprintf(stderr, fmt, ap);/* print the input*/
	va_end(ap);
	if (err)
		fprintf(stderr, ": %s (%d)\n", strerror(err), err);

	if (status)
		EXIT(status);
}
